package online.shenme.itcast.dao;

import online.shenme.itcast.entity.User;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class UserDao {
    private static final HashMap<String, User> users = new HashMap<>();

    public HashMap<String, User> AllUser() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("project/src/online/shenme/itcast/file/user.txt")));
        String s;
        while ((s = br.readLine()) != null) {
            if (!s.startsWith("#")) {
                String[] split = s.split(":", 5);
                users.put(split[0], new User(split[0], split[1], split[2], split[3], split[4]));
            }
        }
        return users;
    }
}
